package reco.db.validation;

import static org.apache.commons.lang.StringUtils.isBlank;

import org.apache.commons.validator.CreditCardValidator;

import reco.db.Constraint;

public class CreditCardConstraint extends Constraint<String> {

    private static final CreditCardValidator VALIDATOR = new CreditCardValidator();

    public CreditCardConstraint() {
        super("creditCard", "isNotCreditCard");
    }

    @Override
    public boolean validate(String value) {
        if (isBlank(value)) {
            return true;
        }
        return VALIDATOR.isValid(value);
    }

    @Override
    public Object[] getErrorArguments() {
        return null;
    }
}
